home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak Vol F-12
/
(Vol F-12) Jun 02 2012.iso
/
Screensaver
/
screensaver_installer.exe
/
____swmx
/
scripts
/
frame_1
/
DoAction_19.as
< prev
next >
Wrap
Text File
|
2004-10-21
|
9KB
|
303 lines
_global.ScreenweaverFlashInterface = function()
{
};
Object.registerClass("Screenweaver Interface",ScreenweaverFlashInterface);
ScreenweaverFlashInterface.prototype.init = function()
{
swInterface.setupConnections();
swEvents.init();
};
Object.registerClass("Screenweaver Flash Interface",ScreenweaverFlashInterface);
ScreenweaverFlashInterface.prototype._init = function()
{
this.ID = "Screenweaver Flash Interface build 5.08";
this.swEvents = new ScreenweaverEvents();
this.swDebug = new ScreenweaverDebug();
this.swSystem = new ScreenweaverSystem();
this.swApplication = new ScreenweaverApplication();
this.swWindow = new ScreenweaverWindow();
this.swGlobalMouse = new ScreenweaverGlobalMouse();
this.swFile = new ScreenweaverFile();
this.swScript = new ScreenweaverScript();
_global.swInterface = this;
_global.swEvents = this.swEvents;
_global.swDebug = this.swDebug;
_global.swSystem = this.swSystem;
_global.swApplication = this.swApplication;
_global.swWindow = this.swWindow;
_global.swGlobalMouse = this.swGlobalMouse;
_global.swFile = this.swFile;
_global.swScript = this.swScript;
swDebug.apiTrace("Initializing " + this.ID);
this.callbackIDCount = 1;
this.nextCallbackID = -1;
this.callbackStack = [];
this.lcr = new LocalConnection();
this.lcr.allowDomain = function()
{
return true;
};
this.lcr.Onreceive = function(UniqueID, WindowData, ApplicationData, SystemColors, SystemData, Windows, Files)
{
swWindow.Data = WindowData;
swApplication.Data = ApplicationData;
swApplication.Files = Files;
swApplication.Windows = Windows;
swSystem.Data = SystemData;
swSystem.Data.monitors = new Array(args.monitorCount);
swSystem.Data.Colors = SystemColors;
swInterface.lcr.close();
delete swInterface.lcr;
swInterface.LCSWF_receiver_name = "LCreceive_SWF_" + swWindow.Data.HostHandle.toString();
swInterface.LCSWMX_receiver_name = "LCreceive_SWMX_" + swWindow.Data.HostHandle.toString();
swApplication.parseCommandLine();
getURL("FSCommand:sw_callbackProcessed",UniqueID);
fscommand("sw_windowDatareceived");
};
this.lcr.success = false;
i = 0;
while(i < 10)
{
this.lcr.success = this.lcr.connect("sw_WindowData");
if(this.lcr.success)
{
break;
}
i++;
}
if(!this.lcr.success)
{
swDebug.apiError("Failed setting up listener for receiving window data.");
return undefined;
}
swDebug.apiTrace("Successfully connected to Window Data source.");
swInterface.getWindowData();
};
ScreenweaverFlashInterface.prototype.getWindowData = function()
{
fscommand("sw_requestWindowData");
};
ScreenweaverFlashInterface.prototype.setupConnections = function()
{
swInterface.LCreceive.close();
swInterface.LCsend.close();
delete swInterface.LCreceive;
delete swInterface.LCsend;
swInterface.LCreceive = new LocalConnection();
swInterface.allowDomain = function()
{
return true;
};
swInterface.LCreceive.callMethod_receive = swInterface.genericCallback;
var tryCount = 0;
while(!swInterface.LCreceive.connect(swInterface.LCSWF_receiver_name) && tryCount < 3)
{
tryCount++;
swDebug.apiTrace("Failed to initialize tunnel.");
}
if(tryCount == 3)
{
swDebug.apiTrace("ERROR: Cannot setup communications.\nThis might be a Flash 5 movie?");
}
swInterface.LCsend = new LocalConnection();
swInterface.LCsend.onStatus = function(infoObject)
{
if(infoObject.level == "error")
{
swDebug.trace("Failed tunneling data.");
}
};
};
ScreenweaverFlashInterface.prototype.closeConnections = function()
{
swInterface.LCreceive.close();
swInterface.LCsend.close();
};
ScreenweaverFlashInterface.prototype.genericCallback = function(UniqueID, ID)
{
if(ID == 0)
{
if(UniqueID != 0)
{
getURL("FSCommand:sw_callbackProcessed",UniqueID);
}
return undefined;
}
var i = 0;
while(i < swInterface.callbackStack.length)
{
if(swInterface.callbackStack[i].ID == ID)
{
var args = [];
j = 2;
while(j < arguments.length)
{
args.push(arguments[j]);
j++;
}
swInterface.callbackStack[i].Callback.apply(swInterface.callbackStack[i].scope,args);
if(!swInterface.callbackStack[i].Static)
{
swInterface.nextCallbackID = ID;
swInterface.callbackStack.splice(i,1);
}
if(UniqueID != 0)
{
getURL("FSCommand:sw_callbackProcessed",UniqueID);
}
break;
}
i++;
}
};
ScreenweaverFlashInterface.prototype.addCallback = function(toAdd, §static§, scope)
{
if(typeof toAdd ne "function")
{
if(toAdd != undefined && toAdd != 0)
{
swDebug.ApiError("Value passed for Callback is not a valid function.");
}
return 0;
}
this.newEntry = {Callback:toAdd,Scope:(scope != undefined ? scope : this),Static:(!eval("static") ? false : true)};
if(swInterface.nextCallbackID > 0)
{
this.newEntry.ID = swInterface.nextCallbackID;
swInterface.nextCallbackID = -1;
}
else
{
this.newEntry.ID = swInterface.callbackIDCount;
swInterface.callbackIDCount = swInterface.callbackIDCount + 1;
}
swInterface.callbackStack.push(this.newEntry);
return this.newEntry.ID;
};
ScreenweaverFlashInterface.prototype.getCallback = function(ID)
{
var i = 0;
while(i < swInterface.callbackStack.length)
{
if(swInterface.callbackStack[i].ID == ID)
{
return swInterface.callbackStack[i];
}
i++;
}
return undefined;
};
ScreenweaverFlashInterface.prototype.pushArg = function(argument)
{
getURL("FSCommand:sw_pushArgument",argument);
};
ScreenweaverFlashInterface.prototype.callDLLMethod = function(source, method, args, callback, scope)
{
this.apiTrace("callDLLMethod" + swInterface.LCSWMX_receiver_name);
this.LCsend.onStatus = function(status)
{
};
var CallbackID = swInterface.addCallback(callback,false,scope);
this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,"callDLLMethod",callbackID,source,method,args);
};
ScreenweaverFlashInterface.prototype.callMethod = function(method, args, callback, §static§, scope)
{
if(callback == undefined)
{
callback = 0;
}
if(eval("static") == undefined)
{
set("static",false);
}
var CallbackID = 0;
if(callback != undefined && callback != 0)
{
CallbackID = swInterface.addCallback(callback,eval("static"),scope);
}
var retry = 0;
while(this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,method,CallbackID,args) == false)
{
if(retry > 4)
{
swDebug.trace("Fatal error: unable to send data to Screenweaver.");
break;
}
swDebug.trace("Error sending data to player. Retrying...");
swInterface.setupConnections();
retry += 1;
}
return CallbackID;
};
ScreenweaverFlashInterface.prototype.callComMethod = function(method, args, callback, scope, §static§)
{
if(!(args instanceof Object))
{
args = {e:"-"};
}
if(eval("static") == undefined)
{
set("static",false);
}
return swInterface.callMethod(method,args,callback,eval("static"),scope);
};
ScreenweaverFlashInterface.prototype.callMethod_stack = function(method, args, callback, §static§, scope)
{
var callback_method = function(method, args, callback, §static§, scope)
{
swInterface.callMethod(method,args,callback,eval("static"),scope);
clearInterval(arguments.callee.intId);
};
setInterval(callback_method,100,method,args,callback,eval("static"),scope);
};
ScreenweaverFlashInterface.prototype.callMethod_CBID = function(method, args, callbackID)
{
this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,method,callbackID,args);
};
ScreenweaverFlashInterface.prototype.setEventListener = function(event, callback)
{
this.Args = new Object();
this.Args.Event = event;
this.Args.CallbackID = swInterface.addCallback(callback,true);
this.OnReturn = function(success)
{
if(!success)
{
swDebug.apiTrace("Failed setting listner for event: " + event);
}
};
swInterface.callMethod("setEventListener",this.args,this.OnReturn);
};
ScreenweaverFlashInterface.prototype.clearEventListener = function(event)
{
this.Args = new Object();
this.Args.Event = event;
this.OnReturn = function(success, ID)
{
if(!success)
{
swDebug.apiTrace("Failed to clear event");
}
};
swInterface.callMethod("clearEventListener",this.args,this.OnReturn);
};
ScreenweaverFlashInterface.prototype.createBuffer = function(size)
{
var result;
i = 0;
while(i <= size)
{
result += " ";
i++;
}
return result;
};
if(_global.swInterface == undefined)
{
_global.swInterface = new ScreenweaverFlashInterface();
swInterface._init();
}
swInterface.onChanged = function()
{
};